package tr.edu.metu.is.mega.client.service;

import java.util.List;

import tr.edu.metu.is.mega.common.dto.AnnouncementDTO;
import tr.edu.metu.is.mega.common.dto.CourseDTO;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;

/**
 * Gwt announcement service.
 */
@RemoteServiceRelativePath("../GwtAnnouncementService")
public interface GwtAnnouncementService extends RemoteService {

    /**
     * Utility class for simplifying access to the instance of async service.
     */
    public static class Util {

        private static GwtAnnouncementServiceAsync instance;

        public static GwtAnnouncementServiceAsync getInstance() {
            if (instance == null) {
                instance = GWT.create(GwtAnnouncementService.class);
            }
            return instance;
        }
    }

    /**
     * Creates an announcement.
     * 
     * @param announcement announcement
     * @return announcement
     */
    public AnnouncementDTO createAnnouncement(AnnouncementDTO announcement);

    /**
     * Updates a announcement.
     * 
     * @param announcement announcement
     * @return announcement
     */
    public AnnouncementDTO updateAnnouncement(AnnouncementDTO announcement);

    /**
     * Deletes a announcement.
     * 
     * @param announcement announcement
     */
    public void deleteAnnouncement(AnnouncementDTO announcement);

    /**
     * Returns list of announcement in a course.
     * 
     * @param course course
     * @return announcement list
     */
    List<AnnouncementDTO> getAnnouncements(CourseDTO course);

}
